/*
	ACDM_start.c

	contains the init routines for the ACDM

	Author: Aidan Goddard 23/10/13
*/

#include"../general/driver_error_codes.h"
#include"../../klib/headers/ktypes.h"
#include"../../klib/headers/klib_message_passing.h"
#include"../../klib/headers/klib_proc_threads.h"

// global vars
static char *key = "ACDM channel key hello!";
static uint8_t msg_buffer[256];

// main start function
uint32_t ACDM_INIT(uint32_t *error)
{
	// find the message channel
	MSG_CHANNEL channel = __KLIB__MSGFindChannel(key, 12);
	if(channel == 0)
	{
		return 0xffffffff;
	}
	*error = __KLIB__MSGClientBindChannel(channel, 0xdeadbeefbabe0000);
	if(*error != MSG_SUCCESS)
	{
		return 0xfffffffe;
	}
	*error = __KLIB__MSGClientSendSync(channel, msg_buffer, 0xdeadbeefbabe0000);
	if(*error != MSG_SUCCESS)
	{
		return 0xfffffffd;
	}

	return 0;
}